package com.aaa;

import java.sql.*;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Test test = new Test();
		String username = "aaa";
		String password = "111";
		Boolean bl = test.login(username, password);
		System.out.print(bl.toString());
	}
	
	public Boolean login(String username,String password){
		try {
			Class.forName("com.mysql.jdbc.Driver");
			Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","123456");
			Statement stm = con.createStatement();
			ResultSet rest = stm.executeQuery("select * from test_user where username='" + username + "'and userpwrd = '" + password + "'");
			if (rest.first()) {
				return true;				
			} else {
				return false;
			}
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

}
